<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
 <head>
  <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  <title>发送编码过的邮件</title>
 </head>
 <body class="docs"><div id="layout">
  <div id="layout-content"><div id="function.mb-send-mail" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">mb_send_mail</h1>
  <p class="verinfo">(PHP 4 &gt;= 4.0.6, PHP 5, PHP 7)</p><p class="refpurpose"><span class="refname">mb_send_mail</span> &mdash; <span class="dc-title">发送编码过的邮件</span></p>

 </div>
   
 <div class="refsect1 description" id="refsect1-function.mb-send-mail-description">
  <h3 class="title">说明</h3>
   <div class="methodsynopsis dc-description">
   <span class="methodname"><strong>mb_send_mail</strong></span>
    ( <span class="methodparam"><span class="type">string</span> <code class="parameter">$to</code></span>
   , <span class="methodparam"><span class="type">string</span> <code class="parameter">$subject</code></span>
   , <span class="methodparam"><span class="type">string</span> <code class="parameter">$message</code></span>
   [, <span class="methodparam"><span class="type">string</span> <code class="parameter">$additional_headers</code><span class="initializer"> = <strong><code>NULL</code></strong></span></span>
   [, <span class="methodparam"><span class="type">string</span> <code class="parameter">$additional_parameter</code><span class="initializer"> = <strong><code>NULL</code></strong></span></span>
  ]] ) : <span class="type">bool</span></div>

  <p class="para rdfs-comment"> 
   发送邮件。邮件头和内容根据 <span class="function"><a href="mb_language.html" class="function">mb_language()</a></span> 设置来转换编码。
   这是 <span class="function"><a href="mail.html" class="function">mail()</a></span> 的一个包装器函数，所以详情参见 <span class="function"><a href="mail.html" class="function">mail()</a></span>。
  </p>
 </div>


 <div class="refsect1 parameters" id="refsect1-function.mb-send-mail-parameters">
  <h3 class="title">参数</h3>
  <p class="para">
   <dl>

    
     <dt>
<code class="parameter">to</code></dt>

     <dd>

      <p class="para">
       被发送到该邮件地址。可通过逗号分隔地址的 <code class="parameter">to</code> 来指定多个收件人。
       该参数不会被自动编码。
      </p>
     </dd>

    
    
     <dt>
<code class="parameter">subject</code></dt>

     <dd>

      <p class="para">
       邮件标题。
      </p>
     </dd>

    
    
     <dt>
<code class="parameter">message</code></dt>

     <dd>

      <p class="para">
       邮件消息。
      </p>
     </dd>

    
    
     <dt>
<code class="parameter">additional_headers</code>(可选)</dt>

     <dd>

      <p class="para">
       String to be inserted at the end of the email header.
      </p>
      <p class="para">
       This is typically used to add extra headers (From, Cc, and Bcc).
       Multiple extra headers should be separated with a CRLF (\r\n).
       Validate parameter not to be injected unwanted headers by attackers.
      </p>
      <blockquote class="note"><p><strong class="note">Note</strong>: 
       <p class="para">
        When sending mail, the mail <em class="emphasis">must</em> contain
        a <em>From</em> header. This can be set with the 
        <code class="parameter">additional_headers</code> parameter, or a default
        can be set in <var class="filename">php.ini</var>.
       </p>
       <p class="para">
        Failing to do this will result in an error
        message similar to <em>Warning: mail(): &quot;sendmail_from&quot; not
        set in php.ini or custom &quot;From:&quot; header missing</em>.
        The <em>From</em> header sets also
        <em>Return-Path</em> under Windows.
       </p>
      </p></blockquote>
      <blockquote class="note"><p><strong class="note">Note</strong>: 
       <p class="para">
        If messages are not received, try using a LF (\n) only.
        Some Unix mail transfer agents (most notably
        <a href="http://www.qmail.org/" class="link external">&raquo;&nbsp;qmail</a>) replace LF by CRLF
        automatically (which leads to doubling CR if CRLF is used).
        This should be a last resort, as it does not comply with
        <a href="http://www.faqs.org/rfcs/rfc2822" class="link external">&raquo;&nbsp;RFC 2822</a>.
       </p>
      </p></blockquote>
     </dd>

    
    
     <dt>
<code class="parameter">additional_parameter</code></dt>

     <dd>

      <p class="para">
       <code class="parameter">additional_parameter</code> 是一个 MTA 命令行参数。
       在使用 sendmail 时对设置正确的返回路径头很有帮助。
      </p>
      <p class="para">
       This parameter is escaped by <span class="function"><a href="escapeshellcmd.html" class="function">escapeshellcmd()</a></span> internally
       to prevent command execution. <span class="function"><a href="escapeshellcmd.html" class="function">escapeshellcmd()</a></span> prevents
       command execution, but allows to add addtional parameters. For security reason,
       this parameter should be validated.
      </p>
      <p class="para">
       Since <span class="function"><a href="escapeshellcmd.html" class="function">escapeshellcmd()</a></span> is applied automatically, some characters
       that are allowed as email addresses by internet RFCs cannot be used. Programs
       that are required to use these characters <span class="function"><a href="mail.html" class="function">mail()</a></span> cannot be used.
      </p>
      <p class="para">
       The user that the webserver runs as should be added as a trusted user to the
       sendmail configuration to prevent a &#039;X-Warning&#039; header from being added
       to the message when the envelope sender (-f) is set using this method.
       For sendmail users, this file is <var class="filename">/etc/mail/trusted-users</var>.
      </p>
     </dd>

    
   </dl>

  </p>
 </div>


 <div class="refsect1 returnvalues" id="refsect1-function.mb-send-mail-returnvalues">
  <h3 class="title">返回值</h3>
  <p class="para">
   成功时返回 <strong><code>TRUE</code></strong>， 或者在失败时返回 <strong><code>FALSE</code></strong>。
  </p>
 </div>

 

 <div class="refsect1 seealso" id="refsect1-function.mb-send-mail-seealso">
  <h3 class="title">参见</h3>
  <p class="para">
   <ul class="simplelist">
    <li class="member"><span class="function"><a href="mail.html" class="function" rel="rdfs-seeAlso">mail()</a> - 发送邮件</span></li>
    <li class="member"><span class="function"><a href="mb_encode_mimeheader.html" class="function" rel="rdfs-seeAlso">mb_encode_mimeheader()</a> - 为 MIME 头编码字符串</span></li>
    <li class="member"><span class="function"><a href="mb_language.html" class="function" rel="rdfs-seeAlso">mb_language()</a> - 设置/获取当前的语言</span></li>
   </ul>
  </p>
 </div>


</div></div></div></body></html>